package zero.tech.wsnet.common;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import zero.tech.core.find.DynamicFind;
import zero.tech.wsnet.data.IRES;

public class ResNodeProcessManager extends DynamicFind {
	private static final Map<String, Class<?>> processClazzMap = new ConcurrentHashMap<String, Class<?>>();

	private ResNodeProcessManager() {
	}

	private static ResNodeProcessManager processManager = new ResNodeProcessManager();

	public static ResNodeProcessManager getManager() {
		return processManager;
	}

	@Override
	public boolean verification(Class<?> clazz) {
		return annotationOn(clazz, IRES.class);
	}

	@Override
	public void findClass(Class<?> clz) throws Exception {
		IRES iProcess = clz.getAnnotation(IRES.class);
		processClazzMap.put(iProcess.code(), clz);
	}

	public Class<?> getProcess(String code) {
		return processClazzMap.get(code);
	}

	@Override
	public void afterFind() {
	}

	@Override
	public void beforeFind() {
	}
}
